/*
 * @Description: 全图显示
 */

import BaseCommand from "@/core/Frame/BaseClass/BaseCommand";
import  { GlobeFlyTo } from "@/utils/CommonUtils";
import BaseMap from "@/core/PIEEarth/BaseMap";


class FullExtentCommand extends BaseCommand {
    viewer: any;
    globeControl: any;
    globe: any;

    constructor(params: any) {
        super();
        this.viewer = params.viewer;
        this.globeControl = this.viewer.getGlobeControl();
        this.globe = this.viewer.getGlobe();
    };


    execute(option: any) {

        let  baseMapObj = new BaseMap("");
        let  center=baseMapObj.option.center;
        console.log("====center",center);
        const targetLon=center[0];//116.4;
        const targetLat=center[1];//39.9;
        const targetHeight = 9000000;
        const time = 4 * 1000;
        GlobeFlyTo(this.globe,targetLon, targetLat, targetHeight, time);
        this.globe.refresh(false, false);
        option.checked = false;
    }

    release() {
        const { globeControl } = this;
        const { PIE } = window;
        globeControl.setGlobeTool(PIE.GlobeToolType.Pan);
    }

    isEnable(option: any) {
        return true
    }
}

export default FullExtentCommand
